<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<%@ include file="../../header.jsp" %>
</head>

<fieldset i="">

<body>

 <form id="formAdd" class="layui-form">
 
 <div class="layui-form-item">
     <label class="layui-form-label">学号</label>
        <div class="layui-input-block">
        <input type= "text" name="studentId" placeholder="请输入学号" class="layui-input" style="width: 150px;"></input>
        </div>
 </div>
 
<div class="layui-form-item">
   <label class ="layui-form-label">姓名</label>
   <div class="layui-input-block">
   <input type="text" name="studentName" placeholder="请输入姓名" class="layui-input" style="width:150px">
   
   </div>
   
</div>
<div class="layui-form-item">
   <label class ="layui-form-label">年龄</label>
   <div class="layui-input-block">
   <input type="text" name="age"  placeholder="请输入年龄" class="layui-input" style="width:150px">
   
   </div>
  </div> 
   
  <div class="layui-form-item">
   <label class ="layui-form-label">性别</label>
   <div class="layui-input-block">
   <input type="radio" name="studentSex"  class="layui-input" style="width:150px" value="男" title ="男">
   <input type="radio" name="studentSex"   class="layui-input" style="width:150px" value ="女" title="女">
   
   </div>
  
</div>

</div>

 	 <div class="layui-form-item" id ="选课信息">
		<label class="layui-form-label">选课信息</label>
		<div class="layui-input-block" id="courseIdd" name="courseId">
			
			
		</div>
	</div>	





  <div class="layui-form-itme">
   <div class="layui-input-block">
        <input  type="hidden" id="selectId" value = "查询" onclick="select1()" style="width:80px"  class="layui-btn"></input>
   <input type="button" name ="action" value="添加" lay-submit lay-filter="add" class="layui-btn"></input>
  <input type="javascript:;"  class="layui-btn" onclick="close()" value="关闭" style="width:80px" ></input>
  <button type="reset"  title="重置"  class="layui-btn">重置</button>
   </div>
</div>
 </form>

</body>

</fieldset>
<script src="../../static/js/base.js"></script>
<script type="text/javascript">
element.render();


function select1(){
	 
	
	
	
	ajax("/StudentMangers/CourseServlet",{action:"查询课程"},"json",function(data){
		
		    
		
		     var optc =""
		     
			
			  
			
			     $.each(data,function(i,dom){
			    	
			    	var course = dom.courseName +" ("+dom.courseId+")";
			    
			    	optc += '<input type="checkbox"  title="'+course+'" name="courseId"  value="'+dom.courseId+'"  >'
			    	
			    	
			     })
			     
			     $("#courseIdd").html(optc);
			 
		       form.render();
	})
	
	
}


refresh();

function refresh(){
	 $("#selectId").click();	
	}



formSubmit("/StudentMangers/StudentServlet","submit(add)","text",function(data){
		
	if (data == "1") {
								
					layer.msg("添加成功",close)				
				} else if (data == "0") {
					layer.msg("添加失败,该学号已经存在");
				} else {
					layer.msg("添加失败");
				}
	
	
	
			})
			
function close(){
	var index=parent.layer.getFrameIndex(window.name); //获取当前窗口的name
    parent.layer.close(index);//关闭窗口
}			
</script>
</html>